package com.star.starp.vo;

import com.star.starp.config.SystemConfig;
import lombok.Data;

/***
 * @className: R
 * @author: Alex
 * @date: 2022/1/2 17:17
 */
@Data
public class R {
    private int code;
    private String msg;
    private Object data;

    public static R createR(int code, String msg, Object data) {
        R r = new R();
        r.setCode(code);
        r.setMsg(msg);
        r.setData(data);
        return r;
    }

    public static R ok(String msg, Object data) {
        return createR(SystemConfig.R_OK, msg, data);
    }

    public static R ok(Object data) {
        return createR(SystemConfig.R_OK, "OK", data);
    }

    public static R ok() {
        return createR(SystemConfig.R_OK, "OK", null);
    }

    public static R fail(String msg) {
        return createR(SystemConfig.R_FAIL, msg, null);
    }

    public static R fail() {
        return createR(SystemConfig.R_FAIL, "FAIL", null);
    }
}
